home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 4.0 KB | 164 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWEventU.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWEVENTU_H
- #include "FWEventU.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__EVENTS__)
- #include <Events.h>
- #endif
-
- #if defined(FW_BUILD_WIN) && !defined(_INC_WINDOWS)
- #include <windows.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #pragma segment fwevents
-
- //----------------------------------------------------------------------------------------
- // ::FW_IsKeyPressed
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_FUNC_ATTR FW_IsKeyPressed(unsigned short theKey)
- {
- #ifdef FW_BUILD_MAC
- KeyMap theKeyMap;
- ::GetKeys(theKeyMap);
- const unsigned char *theKeys = (const unsigned char *) theKeyMap;
- return ((theKeys[theKey >> 3] >> (theKey & 7)) & 1);
- #endif
-
- #ifdef FW_BUILD_WIN
- return ((::GetKeyState(theKey) & 0x8000) != 0);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_GetMouseLocation
- //----------------------------------------------------------------------------------------
- // return value in frame coordinate
-
- FW_CPoint FW_FUNC_ATTR FW_GetMouseLocation(Environment* ev, ODFacet* facet)
- {
- FW_SPlatformPoint windowLoc;
-
- ODWindow* window = facet->GetWindow(ev);
- ODPlatformWindow plfmWindow = window->GetPlatformWindow(ev);
-
- #ifdef FW_BUILD_MAC
- GrafPtr curPort;
- ::GetPort(&curPort);
- ::SetPort(plfmWindow);
- ::GetMouse(&windowLoc);
- ::SetPort(curPort);
- #endif
-
- #ifdef FW_BUILD_WIN
- ::GetCursorPos(&windowLoc);
- ::ScreenToClient(plfmWindow, &windowLoc);
- #endif
-
- FW_CAcquiredODTransform aqTransform = facet->
- #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
- AcquireWindowFrameTransform(ev, NULL);
- #else
- GetWindowFrameTransform(ev, NULL);
- #endif
-
- FW_CPoint point(windowLoc);
- point.InverseTransform(ev, aqTransform);
- return point;
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_GetMouseLocation
- //----------------------------------------------------------------------------------------
- // return value in content coordinate
-
- FW_CPoint FW_FUNC_ATTR FW_GetMouseLocation(ODWindow* theODWindow, FW_CGraphicContext& theGC)
- {
- FW_SPlatformPoint plformLoc;
-
- #ifdef FW_BUILD_MAC
- ::GetMouse(&plformLoc);
- #endif
-
- #ifdef FW_BUILD_WIN
- ::GetCursorPos(&plformLoc);
- ODPlatformWindow plfmWindow = theODWindow->GetPlatformWindow(::somGetGlobalEnvironment());
- ::ScreenToClient(plfmWindow, &plformLoc);
- #endif
-
- return theGC.DeviceToLogical(plformLoc);
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_WaitMouseUp
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_FUNC_ATTR FW_WaitMouseUp()
- {
- #ifdef FW_BUILD_MAC
- return ::WaitMouseUp();
- #endif
- #ifdef FW_BUILD_WIN
- MSG event;
- if (::PeekMessage(&event, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE))
- {
- return event.message != WM_LBUTTONUP &&
- event.message != WM_RBUTTONUP &&
- event.message != WM_LBUTTONDOWN &&
- event.message != WM_RBUTTONDOWN;
- }
- return TRUE;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // ::FW_WaitFor
- //----------------------------------------------------------------------------------------
-
- void FW_WaitFor(long tickCount)
- {
- #ifdef FW_BUILD_MAC
- long targetTick = ::TickCount() + tickCount;
- while (::TickCount() <= targetTick) {}
- #endif
- #ifdef FW_BUILD_WIN
- FW_DEBUG_MESSAGE("Not Yet Implemented");
- #endif
- }
-
-